Skip to content

Conversation

@NeedleInAJayStack
Copy link
Member

@NeedleInAJayStack NeedleInAJayStack commented Nov 8, 2025

This fixes an issue observed in downstream code, where awaiting a GraphQL subscription with makeAsyncIterator().next() results in an error of Fatal error: attempt to await next() on more than one task. This encapsulates the consumption of the underlying resolver stream in a single cancellable task so that downstream code does not share the underlying stream iterator.

This also fixes an issue where lists were not executed in parallel.

This fixes an issue observed in downstream code, where awaiting a GraphQL subscription with `makeAsyncIterator().next()` results in an error of `Fatal error: attempt to await next() on more than one task`. This encapsulates the consumption of the underlying resolver stream in a single cancellable task so that downstream code does not share the underlying stream iterator.
Copy link

@JaapWijnen JaapWijnen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Is there a way to reliably reproduce the error? Can we add that as a test to prove that this is now fixed?

@NeedleInAJayStack
Copy link
Member Author

Thanks for the review Jaap!

Is there a way to reliably reproduce the error? Can we add that as a test to prove that this is now fixed?

Great thought! Unfortunately, I haven't had much luck getting a minimal reproducer to add as a test. My downstream package injects an AsyncMerge3Sequence from swift-async-algorithms into the GraphQL subscription resolver and fatal errors on this line before the fix in this PR. In total honesty, I don't understand much of what's going on in that sequence type and it might be a bug in that package. In any case, I'd rather not bring in that dependency for a unit test, and my attempts to replicate by starting up multiple tasks that await iterators all seem to work fine on main.

Previously the `await group` was inside the for loop, effectively making it an async queue, where operations were performed in serial.
@NeedleInAJayStack NeedleInAJayStack merged commit 6e483ae into GraphQLSwift:main Nov 12, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants